package com.cta.service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.cta.constant.Gender;
import com.cta.entity.Contact;
import com.cta.entity.PBX;
import com.cta.entity.Site;
import com.cta.exception.CTAServiceException;

public interface SiteService {

	/**
	 * create Site
	 * 
	 * @param name
	 * @param description
	 */
	public Site createSite(String name, String description, Long parentId);

	/**
	 * find all Sites
	 * 
	 * @return
	 */
	public List<Site> findAllSites();

	/**
	 * find all child site of parent id
	 * 
	 * @param parentId
	 * @return
	 */
	public List<Site> findAllChildSite(Long parentId);

	/**
	 * find root site
	 * 
	 * @param parentId
	 * @return
	 */
	public Site findRootSite();

	/**
	 * find site by name
	 * 
	 * @param name
	 * @return
	 */
	public Site findSiteByName(String name);

	/**
	 * update site base on id
	 * 
	 * @param id
	 * @param name
	 * @param description
	 * @throws CTAServiceException
	 */
	public void updateSite(Long id, String name, String description) throws CTAServiceException;

	/**
	 * create contact
	 * 
	 * @param name
	 * @param fullName
	 * @param gender
	 * @param birthday
	 * @param email
	 * @param phone
	 * @param assignTo
	 * @param address
	 * @return
	 */
	public Contact createUser(String name, String station, String authorizationCode, String fullName, String gender,
			String birthday, String email, String mobile, String home, String fax, String password, Long assignTo,
			String address);

	/**
	 * update contact
	 * 
	 * @param name
	 * @param fullName
	 * @param gender
	 * @param birthday
	 * @param email
	 * @param phone
	 * @param assignTo
	 * @param address
	 * @return
	 */
	public Contact updateUser(Long userId, String name, String station, String authorizationCode, String fullName,
			String gender, String birthday, String email, String mobile, String home, String fax, String password,
			Long assignTo, String address);

	/**
	 * find all Contact by parentId( assignTo )
	 * 
	 * @param parentId
	 * @return
	 */
	public List<Contact> findContactByParentId(Long parentId);

	/**
	 * create PBX entity
	 * 
	 * @param name
	 * @param description
	 * @param assignTo
	 * @return
	 */
	public PBX createPBX(String name, String description, Long assignTo);

	/**
	 * update PBX entity
	 * 
	 * @param name
	 * @param description
	 * @param assignTo
	 * @return
	 */
	public void updatePBX(String name, String description, Long pbxId) throws CTAServiceException;

	/**
	 * find all PBX by parentId (assignTo)
	 * 
	 * @param parentId
	 * @return
	 */
	public List<PBX> findPBXByParentId(Long parentId);

	/**
	 * find contact by id
	 * 
	 * @param userId
	 * @return
	 */
	public Contact findContactById(Long userId);

	/**
	 * find pbx by id
	 * 
	 * @param pbxId
	 * @return
	 */
	public PBX findPBXById(Long pbxId);

	/**
	 * find pbx by factory id
	 * 
	 * @param factoryId
	 * @return
	 */
	public List<PBX> findPBXByFactoryId(Long factoryId);

	/**
	 * find all PBX
	 * 
	 * @param parentId
	 * @return
	 */
	public List<PBX> findAllPBX();

	/**
	 * assign all pbx to site node
	 * 
	 * @param assignTo
	 * @param itemselector
	 */
	public void assignPBXToSite(Long assignTo, String itemselector);

	/**
	 * find all PBX which are not assign to site node yet.
	 * 
	 * @param parentId
	 * @return
	 */
	public List<PBX> findAllPBXNotAssign();

	/**
	 * un assign all pbx to site node
	 * 
	 * @param assignTo
	 * @param itemselector
	 */
	public void unAssignPBXToSite(String pbxIds);

	/**
	 * find all contact except super admin
	 * 
	 * @return
	 */
	public List<Contact> findAllContactExceptSuperAdmin();

	/**
	 * get all admin contact
	 * 
	 * @return
	 */
	public List<Contact> findAllAdminContact();

	/**
	 * get all normal contact
	 * 
	 * @return
	 */
	public List<Contact> findAllNormalContact();

	/**
	 * find all contact except super admin
	 * 
	 * @return
	 */
	public List<Contact> findAllContactExceptSuperAdminAndNotAssign();

	/**
	 * assign all user to site node
	 * 
	 * @param assignTo
	 * @param itemselector
	 */
	public void assignUserToSite(Long assignTo, String itemselector);

	/**
	 * un assign all user to site node
	 * 
	 * @param assignTo
	 * @param itemselector
	 */
	public void unAssignUserToSite(String userIds);

	/**
	 * set admin role for site
	 * 
	 * @param siteId
	 * @param userId
	 * @return
	 */
	public Contact setAsAdminSite(Long siteId, Long oldUserId, Long userId);
}
